package com.yan.messagesystem.severice;

import com.yan.messagesystem.domain.Message;
import com.yan.messagesystem.dao.Dao;

import java.util.Scanner;

/**
 * @author taoge
 * @Date 2024/7/31 17:00
 * @Description
 */
public class SevericeImpl implements Severice {

    public static final Scanner INPUT = new Scanner(System.in);
    public static final Dao DAO = new Dao();
    @Override
    public void queryMessage() {
        while (!DAO.queue.isEmpty()){
            System.out.println(DAO.queue.peek());
            DAO.queue.remove();
            System.out.println();
        }
    }

    @Override
    public void addAMessage() {
        Message message = new Message();
        System.out.println("请输入留言人姓名");
        String name = INPUT.next();
        message.setName(name);
        System.out.println("请输入留言日期");
        String date = INPUT.next();
        message.setDate(date);
        System.out.println("请输入留言标题");
        String title = INPUT.next();
        message.setTitle(title);
        System.out.println("请输入留言内容");
        String content = INPUT.next();
        message.setContent(content);
        DAO.queue.add(message);
        System.out.println("留言成功！");
    }
}
